package com.ruoyi.web.controller.scrap;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.scrap.domain.po.ScrapApplyPo;
import com.ruoyi.scrap.domain.vo.ScrapApplyAuditVo;
import com.ruoyi.scrap.domain.vo.ScrapApplyVo;
import com.ruoyi.scrap.service.ScrapApplyInfoService;
import com.ruoyi.scrap.service.ScrapApplyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/scrap/apply/audit")
public class ScrapApplyAuditController extends BaseController {

    @Resource
    ScrapApplyService applyService;

    @Resource
    ScrapApplyInfoService applyInfoService;

    @GetMapping("/list")
    public TableDataInfo list(ScrapApplyPo apply)
    {
        startPage();
        apply.setAuditStatus("0");
        apply.setNextAudit(getUserId());
        List<ScrapApplyPo> list = applyInfoService.getWaitScrapApply(apply);
        return getDataTable(list);
    }

    @PostMapping()
    public AjaxResult audit(@RequestBody ScrapApplyAuditVo auditVo) {
        return toAjax(applyService.audit(auditVo,getLoginUser().getUser()));
    }

}
